package org.example.controller;


import io.swagger.v3.oas.annotations.Operation;
import lombok.extern.slf4j.Slf4j;
import org.example.pojo.CommunityContent;
import org.example.service.ICommunityContentService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author zhx
 * @since 2025-01-17
 */
@Slf4j
@RestController
@RequestMapping("/community-content")
public class CommunityContentController {
    @Autowired
    private ICommunityContentService communityContentService;
//    获取所有社区内容列表
    @GetMapping("/getAllContent")
        public List<CommunityContent> getAllContent(CommunityContent content){
        List<CommunityContent> list= communityContentService.getAllContent(content);
        return list;
    }

    @Operation(summary = "根据用户id来查询相关内容")
    @GetMapping("/getContentByUserId/{userId}")
    public List<CommunityContent> getContentByUserId(@PathVariable("userId") Integer userId){
        return communityContentService.getContentByUserId(userId);
    }

    @Operation(summary = "点赞")
    @GetMapping("/likeContent/{contentId}")
    public void likeContent(@PathVariable("contentId") Integer contentId){
        communityContentService.likeContent(contentId);
    }
    @Operation(summary = "取消点赞")
    @GetMapping("/unlikeContent/{contentId}")
    public void unlikeContent(@PathVariable("contentId") Integer contentId){
        communityContentService.unlikeContent(contentId);
    }

    @Operation(summary = "分享")
    @GetMapping("/shareContent/{contentId}")
    public void shareContent(@PathVariable("contentId") Integer contentId){
        communityContentService.shareContent(contentId);
    }
    @Operation(summary = "取消分享")
    @GetMapping("/unshareContent/{contentId}")
    public void unshareContent(@PathVariable("contentId") Integer contentId){
        communityContentService.unshareContent(contentId);
    }

}
